import {
  mapGetters
} from 'vuex';
const ALL = 2;
export const mixin = {
  data() {
    return {
      'selectType': 0,
      'onlyContent': false
    };
  },
  created() {
    // data数据已经初始化，但是DOM结构渲染完成，组件没有加载
    this.classMap = ['decrease', 'discount', 'guarantee', 'invoice', 'special'];
  },
  'methods': {
    goBack() {
      this.$router.go(-1);
    },
    setType(type) {
      this.selectType = Number(type);
    },
    toggleOnly() {
      this.onlyContent = !this.onlyContent;
    }
  },
  'computed': {
    computedRatings() {
      let foods = [];
      if (!this.rating || !this.rating) return;
      this.rating.forEach(element => {
        if (this.onlyContent && !element.text) return;
        if (this.selectType === ALL || this.selectType === element.rateType) foods.push(element);
      });
      return foods;
    }
  }
};
export const seller = {
  data() {
    return {};
  },
  'computed': {
    ...mapGetters(['seller'])
  }
};
